<template>
    <!-- 文化活动 -->
    <base-breadcrumb :title="$route.meta.title">
        <!-- 搜索 -->
        <searchData :searchData="searchArr" @search="search"></searchData>
        <!-- 表格 -->
        <a-card :bordered="false">
            <!-- <title-name :title="$route.meta.title"></title-name> -->
            <a-button
                class="mb12"
                icon="plus"
                type="primary"
                @click="handleManage(2)"
                v-btnPermission="'lu_0015_add_01'"
                >新增</a-button
            >
            <!-- 表格 -->
            <list-table
                ref="table"
                size="default"
                rowKey="id"
                :columns="columns"
                :request="loadData"
                :alert="true"
                show-size-changer
                show-quick-jumper
                showPagination="auto"
            >
                <template slot="action" slot-scope="text, record">
                    <MoreButton>
                    <a @click="handleManage(0, record)" v-btnPermission="'lu_0015_loo_04'">查看</a>

                    <a @click="handleManage(1, record)" v-btnPermission="'lu_0015_edi_02'">编辑</a>
                    <!-- 删除 -->
                    <a class="del_btn" @click="handleRemove(record.id)" v-btnPermission="'lu_0015_del_03'">删除</a>
                    </MoreButton>
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
import { STable } from '@/components' // 表格
import { getPageUnionActivity, deleteUnionActivity, addUnionBookHouseImport } from '@/api/union/culturalActivities' // api
import Selector from '@/components/Select/Selector'
import BasePage from '@/views/basePage' // 基础配置
import SelectTreeUnion from '@/components/Select/SelectTreeUnion' // 工会
const searchArr = [
    // 搜索框
    {
        name: '活动主题',
        type: 'input',
        value: 'activityName',
    },
    {
        name: '层级',
        type: Selector,
        valueKey: 'unionLevel',
        selectType: '1',
        urlType: 'union',
    },

    {
        name: '工会组织',
        type: SelectTreeUnion,
        valueKey: 'unionOrgId',
        isAuth: false,
    },

    {
        name: '活动日期',
        type: 'dateRange',
        value: 'activityDate',
        attr: {
            rangeFormat: ['activityDateStart', 'activityDateEnd'],
        },
    },
]
const columns = [
    {
        title: '序号',
        width: 80,
        dataIndex: 'index',
        customRender() {
            return arguments[2] + 1
        },
    },
    {
        title: '活动主题',
        ellipsis: true,
        dataIndex: 'activityName',
    },
    {
        title: '层级',
        ellipsis: true,
        dataIndex: 'unionLevelStr',
    },
    {
        title: '工会组织',
        ellipsis: true,
        dataIndex: 'branchComName',
        customRender: (text, record, index) => {
            return record.projectName || record.branchComName || record.companyName
        },
    },
    {
        title: '活动时间',
        ellipsis: true,
        dataIndex: 'activityDate',
    },
    {
        title: '活动地点',
        dataIndex: 'activityAddress',
        ellipsis: true,
    },
    {
        title: '操作',
        dataIndex: 'action',
        width: '180px',
        align: 'center',
        scopedSlots: { customRender: 'action' },
    },
]
export default {
    name:'a'+Date.now(),
    extends: new BasePage(),
    components: {
        STable,
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {}, // 查询参数
            loadData: (parameter) => {
                const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
                return getPageUnionActivity(requestParameters).then((res) => {
                    return res
                })
            }, // 加载数据方法 必须为 Promise 对象
            removeApi: { remove: deleteUnionActivity }, // api
        }
    },
    methods: {
        // 搜索
        search(value) {
            value && (this.queryParam = value)
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record) {
            let query = {
                editModel: type,
            }
            if (record && record.id) {
                query.id = record.id
            }
            this.$router.push({
                name: '/union/culturalActivities/recreationalActivity/updateRecreationalActivity',
                query,
            })
        },
    },
}
</script>
